/*
The MIT License (MIT)

Copyright (c) 2013 Mike Dapiran, Brian May, Richard Pospesel, and Bert Wierenga

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software 
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#pragma once

#include "Hogshead.Common.h"
#include "IHObject.h"

#define ContentH(longName, humanReadableName)\
	public:\
		const char* contentName() { return #humanReadableName ;}\
		static const char* getContentName() {return #humanReadableName;}\
		int getContentID() const {return _content_id;}\
		static int contentID() {return _content_id;}\
		void explicitLoad();\
	private:\
		void readXML(const String& in_xml);\
		void setContentID(int in_id) {_content_id = in_id;}\
		static int _content_id;\
		\
		friend class ContentLibrary;\
		HObjectH(longName)

#define ContentCPP(longName, humanReadableName)\
	int humanReadableName::_content_id;\
	HObjectCPP(longName);

namespace Hogshead
{
	namespace Core
	{
		class IGame;
		class ContentLibrary;

		class IContent : public IHObject
		{
		public:
			IContent(){}
			virtual ~IContent(){}
			virtual const char* contentName() = 0;
			virtual int getContentID() const = 0;
			//virtual IContent* instance() const = 0;
			String getPath() const
			{
				return _path;
			}

			String getKey() const
			{
				return _key;
			}

			int _ref_count;
			
		protected:
			virtual void explicitLoad() = 0;
			virtual void explicitLoadFromData(void* in_data){error("Explicit load from data not implemented for this content type");}
			virtual void setContentID(int in_id) = 0;
			//read the XML file for this piece of content and act accordingly
			virtual void readXML(const String& in_xml) = 0;
			//do any and all loading here including FBX, Xml, Etc.

			String _key;
			String _path;
			
			friend class ContentLibrary;

		};
	}
}